import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;
import java.lang.Character;

public class EventTest extends Jlet
{
	protected void startApp(String args[]){
		Display dis = Display.getDefaultDisplay();
		dis.pushCard(new SampleCard());
        }
	protected void destroyApp(boolean b){
	}
};

class SampleCard extends Card
{
	boolean keyInput = false;
	String keyCode = "";
	int keyValue = 0 ;

	public void paint(Graphics g)
	{
		g.setColor(0xffffff);
		g.fillRect(0,0,getWidth(),getHeight());

		g.setColor(0x000000);
		g.drawString("아무키나 눌러주세요" ,5,10,Graphics.TOP);
		g.drawString("입력된 키값은 : "+keyValue,5,50,Graphics.TOP);
		g.drawString(keyCode+" 입니다 ",5,70,Graphics.TOP);
	}

	protected boolean keyNotify(int type, int key) 
	{
		keyValue = key;
		switch(Display.getGameAction(key)) 
		{
			case EventQueue.CLEAR : keyCode = "CLEAR"; break;
			case EventQueue.DOWN : keyCode = "DOWN"; break;
			case EventQueue.UP : keyCode = "UP"; break;
			case EventQueue.LEFT : keyCode = "LEFT"; break;
			case EventQueue.RIGHT : keyCode = "RIGHT"; break;
			case EventQueue.FIRE : keyCode = "FIRE"; break;
			case EventQueue.SOFT1 : keyCode = "SOFT1"; break;
			case EventQueue.SOFT2 : keyCode = "SOFT2"; break;
			case EventQueue.SOFT3 : keyCode = "SOFT3"; break;
			case EventQueue.SIDE_SEL : keyCode = "SIDE_SEL"; break;
			case EventQueue.SIDE_UP : keyCode = "SIDE_UP"; break;
			case EventQueue.SIDE_DOWN : keyCode = "SIDE_DOWN"; break;
			default : 
				char ch = (char)key;
				keyCode = (new Character(ch))	.toString();
		}
		if(type == EventQueue.KEY_PRESSED) { repaint(); }
		return true;
	}
};
